package com.junhao;

import com.junhao.service.OrderService;
import com.spring.demoApplicationContext;

public class Test {
    public static void main(String[] args) {
        //启动spring
        demoApplicationContext applicationContext = new demoApplicationContext(AppConfig.class);

        //getBean()
//        OrderService orderService =(OrderService) applicationContext.getBean("orderService");
//        System.out.println(orderService);
//        orderService.test();

        //连续四次输出的com.junhao.service.UserService@63947c6b 是一样的说明，这个类是单例
        //原型要在orderService类上面@Scope("prototype")
        //System.out.println(applicationContext.getBean("orderService"));
        //System.out.println(applicationContext.getBean("orderService"));
        //System.out.println(applicationContext.getBean("orderService"));
        //System.out.println(applicationContext.getBean("orderService"));
        // 原型 原型可能会造成GC问题 你就是new太多了  多少个new就多少个初始化
//        com.junhao.service.OrderService@2b193f2d
//        com.junhao.service.OrderService@355da254
//        com.junhao.service.OrderService@4dc63996
//        com.junhao.service.OrderService@d716361

        // 单例 只有一个初始化
//        com.junhao.service.OrderService@63947c6b
//        com.junhao.service.OrderService@63947c6b
//        com.junhao.service.OrderService@63947c6b
//        com.junhao.service.OrderService@63947c6b
        //关闭spring



        //test: BeanPostProcessor
        System.out.println(applicationContext.getBean("orderService"));
    }
}
